package com.da.boot;

import com.da.boot.bean.Car;
import com.da.boot.bean.Pet;
import com.da.boot.bean.User;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * @author JokerDa.
 * @date 2021/1/19 10:44
 * Description:
 */
@SpringBootApplication
public class MainApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(MainApplication.class, args);

        //for (String definitionName : context.getBeanDefinitionNames()) {
        //    System.out.println(definitionName);
        //}

        User user = context.getBean("user", User.class);
        User user2 = context.getBean("user", User.class);
        System.out.println(user);
        System.out.println(user == user2);
        System.out.println(context.getBean("tomcat", User.class));
        boolean pet = user.getPet() == context.getBean("pet");
        System.out.println("是否容器中的宠物:" + pet);
        System.out.println("--------------------------");

        for (String s : context.getBeanNamesForType(Pet.class)) {
            System.out.println(s);
        }

        System.out.println("--------------------------");
        //System.out.println(context.getBean("car", Car.class));
    }
}
